<?php defined( '_VALID_MOS' ) or die( include("404.php") ); ?>
	<div id="content-box">
		<div class="border">
			<div class="padding">
				<div id="toolbar-box">
   			<div class="t">

				<div class="t">
					<div class="t"></div>
				</div>
			</div>
			<div class="m">
				<div class="toolbar" id="toolbar">
<table class="toolbar">
<tr>

<td class="button" id="toolbar-publish">
<a href="#" onclick="javascript:if(document.phpForm.boxchecked.value==0){alert('Vui lòng chọn một mục Menu từ danh sách để');}else{  submitbutton('publish')}" class="toolbar">
<span class="icon-32-publish" title="Bật">
</span>
Bật

</a>
</td>

<td class="button" id="toolbar-unpublish">
<a href="#" onclick="javascript:if(document.phpForm.boxchecked.value==0){alert('Vui lòng chọn một mục Menu từ danh sách để');}else{  submitbutton('unpublish')}" class="toolbar">
<span class="icon-32-unpublish" title="Tắt">
</span>
Tắt
</a>
</td>

<td class="button" id="toolbar-trash">
<a href="#" onclick="javascript:if(document.phpForm.boxchecked.value==0){alert('Vui lòng chọn một mục Menu từ danh sách để');}else{  submitbutton('remove')}" class="toolbar">
<span class="icon-32-trash" title="Sọt rác">
</span>
Sọt rác
</a>
</td>

<td class="button" id="toolbar-new">
<a href=".?com=com_menu&view=item_menu&task=tree&menutypeid=<?php echo $_GET["menutypeid"]; ?>" class="toolbar">
<span class="icon-32-new" title="Thêm mới">
</span>
Thêm mới
</a>
</td>

<td class="button" id="toolbar-help">
<a href="#" onclick="popupWindow('', 'Trợ giúp', 640, 480, 1)" class="toolbar">
<span class="icon-32-help" title="Trợ giúp">
</span>
Trợ giúp
</a>
</td>

</tr></table>
</div>
<div class="header icon-48-menu">
Quản lý các mục menu: <small><small></small></small>
</div>
				<div class="clr"></div>
			</div>
			<div class="b">
				<div class="b">
					<div class="b"></div>
				</div>
			</div>
  		</div>
   		<div class="clr"></div>
		<div id="element-box">
			<div class="t">
		 		<div class="t">
					<div class="t"></div>
		 		</div>
			</div>
			<div class="m">
				
<form method="post" name="phpForm">
	
<table class="adminlist">
	<thead>
	<?php include("../protected/dbconnect.php");
		$sql = "SELECT `menu`.`title`, `menu`.`activated`, `menu`.`order_num`, `menu`.`link`,
				`menu`.`link_id`, `menu`.`type`, `menu`.`target`, `menu`.`menu_type_Id` ,`menu`.`Id`
				FROM `menu` where parent_Id = 0 AND `menu`.`menu_type_id` = ?";
		$cmd = $mysqli->prepare($sql);
		$cmd->bind_param("s", $_GET["menutypeid"]);
		$cmd->execute();
		$cmd->bind_result($title, $activated, $order_num, $link, $link_id, $type, $target, $typeid, $Id);
		$cmd->store_result();
		$sub_space = "&nbsp;&nbsp;&nbsp;|";
		$sub_sign = "_";
	?>
		<tr>
			<th width="20">&nbsp;</th>
			<th class="title"><a href="#">Danh mục menu</a></th>
			<th width="5%" nowrap="nowrap"><a href="#">Đã được bật</a></th>
			<th width="8%" nowrap="nowrap"><a href="javascript:void(0)">Sắp xếp</a></th>
			<th width="20%" class="title"><a href="#">Liên kết</a></th>
			<th width="5%" class="title"><a href="#">Target</a></th>
			<th width="1%" nowrap="nowrap"><a href="#">ID của mục</a></th>
		</tr>
	</thead>	
	<tbody>
		<?php while($cmd->fetch()){?>
			<tr class="row0">
				<td><input type="checkbox" name="cid[]" value="<?php echo $Id; ?>" onclick="isChecked(this.checked);" /></td>
				<td nowrap="nowrap">
				<span class="editlinktip hasTip" title="Nhấp chuột để sửa đổi mục Menu này::<?php echo $title; ?>">					
					<a href=".?com=com_menu&view=item_menu&task=<?php echo $type; ?>.edit&id=<?php echo $Id; ?>&menutypeid=<?php echo $typeid; ?>"><?php echo $sub_space . $sub_sign . $title; ?></a>
				</span>
				</td>
				<td align="center">			
					<?php if($activated == 1) { ?>
						<span class="editlinktip hasTip" title="Đã được bật">
							<a href="javascript:void(0);" onclick="return listItemTask('cb<?php echo $Id; ?>','unpublish')">
							<img src="template/images/tick.png" alt="Đã được bật" border="0" width="16" height="16">
							</a>
						</span>
					<?php } else if ($activated == 0) { ?>			
						<span class="editlinktip hasTip" title="Chưa được bật">
							<a href="javascript:void(0);" onclick="return listItemTask('cb<?php echo $Id; ?>','publish')">
							<img src="template/images/publish_r.png" alt="Chưa được bật" border="0" width="16" height="16">
							</a>
						</span>
					<?php }	?>
				</td>
				<td class="order">
					<span><a href="javascript:void(0);" onclick="return listItemTask('cb<?php echo $Id ?>','orderup')" title="Đi lên">  <img src="template/images/uparrow.png" alt="Đi lên" border="0" width="16" height="16"></a></span>
					<span><a href="javascript:void(0);" onclick="return listItemTask('cb<?php echo $Id ?>','orderdown')" title="Đi Xuống">  <img src="template/images/downarrow.png" alt="Đi Xuống" border="0" width="16" height="16"></a></span>
				</td>
				<td>
					<span class="editlinktip" style="text-transform:capitalize"><?php echo $link.$link_id; ?></span>
				</td>
				<td align="center"><?php echo $target; ?> </td>
				<td align="center"><?php echo $Id; ?> </td>
			</tr>
		<?php
			loadsubmemu($Id, $sub_space, $sub_sign);
		}
		
		function loadsubmemu($id, $sub_space, $sub_sign ){
			include("../protected/dbconnect.php");
			$sql1 = "SELECT `menu`.`title`, `menu`.`activated`, `menu`.`order_num`, `menu`.`link`, `menu`.`link_id`, `menu`.`type`, `menu`.`target`, `menu`.`menu_type_Id`, `menu`.`Id`
					FROM `menu` where parent_Id = $id AND `menu`.`menu_type_id` = ?";
			$cmd1 = $mysqli->prepare($sql1);
			$cmd1->bind_param("s", $_GET["menutypeid"]);
			$cmd1->execute();
			$cmd1->bind_result($title, $activated, $order_num, $link, $link_id, $type, $target, $typeid, $Id);
			$cmd1->store_result();
			if($cmd1->num_rows > 0){
				$sub_space = $sub_space . "&nbsp;&nbsp;&nbsp;|";
				$sub_sign = $sub_sign . "_";
				while($cmd1->fetch()){?>
					<tr class="row0">
						<td><input type="checkbox" name="cid[]" value="<?php echo $Id; ?>" onclick="isChecked(this.checked);" /></td>
						<td nowrap="nowrap">
						<span class="editlinktip hasTip" title="Nhấp chuột để sửa đổi mục Menu này::<?php echo $title; ?>">					
							<a href=".?com=com_menu&view=item_menu&task=<?php echo $type; ?>.edit&id=<?php echo $Id; ?>&menutypeid=<?php echo $typeid; ?>"><?php echo $sub_space . $sub_sign . $title; ?></a>
						</span>
						</td>
						<td align="center">			
							<?php if($activated == 1) { ?>
								<span class="editlinktip hasTip" title="Đã được bật">
									<a href="javascript:void(0);" onclick="return listItemTask('cb<?php echo $Id; ?>','unpublish')">
									<img src="template/images/tick.png" alt="Đã được bật" border="0" width="16" height="16">
									</a>
								</span>
							<?php } else if ($activated == 0) { ?>			
								<span class="editlinktip hasTip" title="Chưa được bật">
									<a href="javascript:void(0);" onclick="return listItemTask('cb<?php echo $Id; ?>','publish')">
									<img src="template/images/publish_r.png" alt="Chưa được bật" border="0" width="16" height="16">
									</a>
								</span>
							<?php }	?>
						</td>
						<td class="order">
							<span><a href="javascript:void(0);" onclick="return listItemTask('cb<?php echo $Id ?>','orderup')" title="Đi lên">  <img src="template/images/uparrow.png" alt="Đi lên" border="0" width="16" height="16"></a></span>
							<span><a href="javascript:void(0);" onclick="return listItemTask('cb<?php echo $Id ?>','orderdown')" title="Đi Xuống">  <img src="template/images/downarrow.png" alt="Đi Xuống" border="0" width="16" height="16"></a></span>							
						</td>
						<td>
							<span class="editlinktip" style="text-transform:capitalize"><?php echo $link.$link_id; ?></span>
						</td>
						<td align="center"><?php echo $target; ?> </td>
						<td align="center"><?php echo $Id; ?> </td>
					</tr>
					<?php loadsubmemu($Id, $sub_space, $sub_sign);
				}
			}
		}
	?>
	</tbody>
	</table>
	<INPUT type=hidden value=submit_com_menu_item_menu_view name=hidden>
	<INPUT type=hidden value=0 name=boxchecked>
	<INPUT type=hidden name=task>
	</form>
				<div class="clr"></div>
			</div>
			<div class="b">
				<div class="b">

					<div class="b"></div>
				</div>
			</div>
   		</div>
		<noscript>
			!Cảnh báo! Javascript phải được bật để chạy được các chức năng trong phần Quản trị		</noscript>
		<div class="clr"></div>
	</div>
	<div class="clr"></div>

</div>
</div>
	<div id="border-bottom"><div><div></div></div></div>
